package jdtprototype;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.eclipse.core.resources.IProject;
import org.eclipse.epsilon.eol.parse.Eol_EolParserRules.newExpression_return;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.PackageDeclaration;
import org.eclipse.jdt.core.dom.TypeDeclaration;

public abstract class JdtElement {
	
	protected Object element;
	protected String name;


	protected HashMap<String, Object> properties = new HashMap<String, Object>();
	
	public JdtElement(){
		//TODO..
	}
	
	public JdtElement(Object element){
		this.element = element;
	}
	
	
	public Object getElement() {
		return element;
	}
	
	public void setElement(String element) {
		this.element = element;
	}
		
	/**
	 * @return the name of the give element
	 */
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public HashMap<String, Object> getProperties() {
		return properties;
	}
	//TODO...
	
}

/**
 * Representation of a Java project type
 * @author Cheng Yun
 *
 */
class JavaProject extends JdtElement{
	List<Package> packages = new ArrayList<Package>();

	public JavaProject(){
		
	}
	public JavaProject (IProject project){
		
		super(project);
		name = project.getName();
	}
	
	public void add(Package packageFragment){
		packages.add(packageFragment);
	}
	
	public List<Package> getPackages() {
		return packages;
	}
	//TODO...
}

/**
 * Representation of a Java package type
 * @author Cheng Yun
 *
 */
class Package extends JdtElement{
	List<Class> classes = new ArrayList<Class>();

	public Package (IPackageFragment packageFragment){
		super(packageFragment);
		name = packageFragment.getElementName();
	}
	
	public void add(Class classtype){
		classes.add(classtype);
	}
	
	public List<Class> getClasses() {
		return classes;
	}
	
	//TODO
}

/**
 * Representation of a Java class type
 * @author Cheng Yun
 *
 */
class Class extends JdtElement{
	List<Method> methods = new ArrayList<Method>();
	
	public Class (TypeDeclaration classtype){
		super(classtype);
		name = classtype.getName().getFullyQualifiedName();
	}
	
	public void add(Method method){
		methods.add(method);
	}
	
	public List<Method> getMethods() {
		return methods;
	}
	//TODO...
}

/**
 * Representation of a Java class type
 * @author Cheng Yun
 *
 */
class Method extends JdtElement{
	public Method (MethodDeclaration method){
		super(method);
		name = method.getName().getFullyQualifiedName();
	}
	//TODO...
}
